<?php
/**
 * YBatchMemory.php
 *
 * @author Hua Yang <htmlcook@gmail.com>
 * @since 2.0
 */

Yii::import('common.components.queue.YMemory');

/**
 * Class YBatchMemory
 */
class YBatchYMemory extends YMemory
{
	/**
	 * @param int $leaseTime
	 * @return bool|mixed
	 */
	public function claimItem($leaseTime = 0)
	{
		if (!empty($this->queue)) {
			reset($this->queue);
			return current($this->queue);
		}
		return false;
	}

	/**
	 * @return array
	 */
	public function getAllItems()
	{
		$result = array();
		foreach ($this->queue as $item) {
			$result[] = $item->data;
		}
		return $result;
	}
} 